{% extends "base.html" %}
{% block title %}预约回执单{% endblock %}
{% block head %}
    {{ super() }}
    <style>

    </style>
{% endblock %}
{% block body %}
    <div class="contianer info-page" style="display: flex;flex-direction: column;">
        {% if examInfo %}
            {% set exams = examInfo["MedicalRequestInfo"]["RequestInfo"] %}
            {% if exams|isDict %}
                {% set exams=exams|parseArray %}
            {% endif %}
            <div class="weui-well well-print font14">
                <div class="text-center">
                    <h2>{{ config.HOSPITAL }}
                        <span class="leftRightCicle"></span>
                    </h2>
                </div>
                <div class="weui-flex text-center onlyBottomBorder">
                    <div class="weui-flex__item">
                        <div>{{ examInfo["PatientInfo"]["PatientName"] }} {{ '男' if examInfo["PatientInfo"]["PatientSex"]=='1' else  '女' }} {{ (examInfo["PatientInfo"]["PatientAge"]+"岁") if examInfo["PatientInfo"]["PatientAge"] }}</div>

                        <div class="bcTarget" style="margin:0 auto;height: 5em;" barWidth="2" barHeight="46">
                            <input type="hidden" value="{{ examInfo["PatientInfo"]['PatientID'] }}">
                        </div>
                        <div class="weui-flex font12 text-disabled">
                            <div class="weui-flex__item text-left">
                                流水号：{{ examInfo["PatientInfo"]["JZLSH"]|ifNoneParseNullString }}
                                <div>住院号：{{ examInfo["PatientInfo"]["InHospitalID"]|ifNoneParseNullString }}</div>
                            </div>
                            <div class="weui-flex__item text-right">
                                床号：{{ examInfo["PatientInfo"]["PatientBedNum"]|ifNoneParseNullString }}
                                <div>诊室：{{ examInfo["PatientInfo"]["PatientDeptName"]|ifNoneParseNullString }}</div>
                            </div>

                        </div>
                    </div>
                </div>
                <div class="weui-flex font12 text-disabled">
                    <div class="weui-flex__item">检查项目</div>
                    <div class="weui-flex__item">部位</div>
                    <div class="weui-flex__item" style="text-align: right">诊断</div>
                </div>
                <div class="onlyBottomBorder">
                    {% for exam in exams %}
                        {% if exam|isDict and exam["ExamList"] %}

                            <div class="weui-flex font12">
                                <div class="weui-flex__item">
                                    {% if exam["ExamList"]["Exam"]|isList %}
                                        {% for ex in exam["ExamList"]["Exam"] %}
                                            {% if loop.index0==0 %}
                                                {{ ex["ExamProject"] }}
                                            {% else %}
                                                {{ ','+ex["ExamProject"] }}
                                            {% endif %}
                                        {% endfor %}
                                    {% else %}
                                        {{ exam["ExamList"]["Exam"]["ExamProject"] }}
                                    {% endif %}
                                </div>
                                <div class="weui-flex__item">
                                    {% if exam["ExamList"]["Exam"]|isList %}
                                        {% for ex in exam["ExamList"]["Exam"] %}
                                            {% if loop.index0==0 %}
                                                {{ ex["ParentBodyPart"] }}
                                            {% else %}
                                                {{ ','+ex["ParentBodyPart"] }}
                                            {% endif %}
                                        {% endfor %}
                                    {% else %}
                                        {{ exam["ExamList"]["Exam"]["ParentBodyPart"] }}
                                    {% endif %}</div>
                                <div class="weui-flex__item"
                                     style="text-align: right">{{ exam["LinChuangZhenDuan"] }}</div>
                            </div>
                        {% endif %}
                    {% endfor %}
                </div>
                <div class="onlyBottomBorder">
                    <div>预约检查日期：{{ exams[0]["ReservationInfo"]["resDate"]|formatDate }}</div>
                    <div>报到时间段：{{ exams[0]["ReservationInfo"]["resTime"] }}</div>
                    <div>检查地址：{{ exams[0]["ExamPlace"]|ifNoneParseNullString }}</div>
                </div>
                <div class="text-disabled">
                    <small>
                        准备事项:<br>
                        1. 报到后请留意大屏叫号信息；<br>
                        2. 如过号请重新取号，请谅解。
                    </small>
                </div>
            </div>
        {% else %}
            <div class="weui-loadmore weui-loadmore_line"><span class="weui-loadmore__tips">无数据返回</span></div>
        {% endif %}
    </div>
{% endblock %}
{% block script %}
    {{ super() }}
    <script src="{{ url_for('page.send_static',filename='js/jquery-barcode.min.js') }}"></script>
    <script type="text/javascript">
        $(".bcTarget").each(function (i, targetQRDiv) {
            var $targetQRDiv = $(targetQRDiv);
            if ($targetQRDiv && $targetQRDiv.children("input").val()) {
                targetStr = $targetQRDiv.children("input").val();
                targetWidth = $targetQRDiv.attr("barWidth");
                if (!targetWidth) {
                    targetWidth = 1;
                }
                targetHeight = $targetQRDiv.attr("barHeight");
                if (!targetHeight) {
                    targetHeight = 23;
                }
                targetType = $targetQRDiv.attr("datatype");
                if (targetType == "qrcode") {
                    $targetQRDiv.qrcode({render: "canvas", width: 200, height: 200, text: targetStr});
                    $targetQRDiv.children("canvas").css('width', 200).css('height', 200);
                    $targetQRDiv.addClass("text-center");
                } else {
                    var encode = "code128";
                    //if (8 === targetStr.length) encode = "ean8";
                    //else if (13 === targetStr.length) encode = "ean13";
                    $targetQRDiv.barcode(targetStr, encode, {
                        barWidth: targetWidth,
                        barHeight: targetHeight,
                        showHRI: true,
                        bgColor: "#fff"
                    });
                }
            }
        })
    </script>
{% endblock %}